<template>
  <div class="planting-code">
    <div class="planting-code-head">
      <img :src="memberAvatar" alt class="planting-code-head-img" />
      <span>{{memberName}}</span>
      <div class="order-status">
        <dl
          v-for="(item, index) in orderStatus"
          :key="index"
          @click="$router.push({ name: 'all-orders', query: { orders_id: item.id } })"
        >
          <dt>
            <img :src="item.img" alt />
          </dt>
          <dd>{{item.title}}</dd>
          <span
            :style="item.number > 99 ? 'width: 30px; border-radius: 30px;' : 'width: 20px;'"
            v-if="item.number && item.number != 0"
          >{{item.number > 99 ? '99+' : item.number}}</span>
        </dl>
      </div>
    </div>
    <div
      class="sample-sending-information"
      @click="$router.push({name: 'sample-sending-information'})"
    >
      <img src="../../assets/images/sample-sending-information-icon.png" alt />
      <span>送样信息</span>
    </div>
    <div class="planting-code-p1">
      <p>
        <span @click="goSampling()">了解如何取样，</span>请点击下方取样方法按钮
      </p>
      <button @click="goSampling()">取样方法</button>
    </div>
    <div class="planting-code-p2">
      <p>土壤检测服务相关问题可拨打</p>
      <span>400-698-7158</span>
      <p>或可在微信公众号在线咨询</p>
    </div>
  </div>
</template>
<script>
import { ordersNumber } from "@/api/common.js";
export default {
  data() {
    return {
      orderStatus: [],
      memberName: "",
      memberAvatar: "",
      inTestCount: "",
      stayPaymentCount: "",
      stayTestCount: "",
      successTestCount: "",
      key: localStorage.getItem("userKey"),
    };
  },
  mounted() {
    this.init();
    this.getordersNumber();
  },
  methods: {
    getordersNumber() {
      ordersNumber({
        key: this.key,
      }).then((res) => {
        let code = res.data.code;
        if (code == 200) {
          let data = res.data.datas.data;
          this.inTestCount = data.in_test_count;
          this.stayPaymentCount = data.stay_payment_count;
          this.stayTestCount = data.stay_test_count;
          this.successTestCount = data.success_test_count;
          this.orderStatus = [
            {
              img: require("../../assets/images/pay-icon-1.png"),
              title: "待付款",
              id: 10,
              number: this.stayPaymentCount,
            },
            {
              img: require("../../assets/images/pay-icon-2.png"),
              title: "待检测",
              id: 20,
              number: this.stayTestCount,
            },
            {
              img: require("../../assets/images/pay-icon-3.png"),
              title: "检测中",
              id: 30,
              number: this.inTestCount,
            },
            {
              img: require("../../assets/images/pay-icon-4.png"),
              title: "已完成",
              id: 40,
              number: null,
            },
          ];
        }
      });
    },
    init() {
      this.memberName = localStorage.getItem("memberName");
      this.memberAvatar = localStorage.getItem("memberAvatar");
    },
    goSampling() {
      this.$router.push({
        name: "sampling",
      });
    },
  },
};
</script>

<style scoped>
.planting-code {
  width: 100%;
  padding-bottom: 30px;
}
.planting-code-head {
  width: 100%;
  background: url("../../assets/images/bg.png");
  background-size: 100% 100%;
  margin-top: -45px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 85px 0 65px;
  box-sizing: border-box;
  border-bottom: 55px solid #fff;
  position: relative;
}
.planting-code-head span {
  font-size: 15px;
  color: #fff;
}
.planting-code-head-img {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-sizing: border-box;
  margin-bottom: 10px;
}
.order-status {
  width: 90%;
  background: #fff;
  display: flex;
  justify-content: space-around;
  padding: 15px 0 20px;
  box-sizing: border-box;
  border-radius: 5px;
  box-shadow: 0px 3px 10px 0px rgba(0, 0, 0, 0.1);
  position: absolute;
  bottom: -40px;
  left: 5%;
}
.order-status dl {
  text-align: center;
  position: relative;
}
.order-status dl img {
  width: 30px;
  height: 30px;
}
.order-status dl dd {
  font-size: 13px;
  color: #262424;
  margin-top: 5px;
}
.order-status dl span {
  position: absolute;
  right: -15px;
  top: -10px;
  color: #333;
  display: block;
  background: #f5222d;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 12px;
  text-align: center;
  line-height: 20px;
  color: #fff;
}
/* .contact-information {
	  width: 100%;
	  padding: 25px 15px 0;
	  box-sizing: border-box;
	  background: #fff;
	}
	.contact-information h2 {
	  color: #262424;
	  font-size: 18px;
	  padding-left: 15px;
	  box-sizing: border-box;
	  position: relative;
	}
	.contact-information h2::before {
	  width: 4px;
	  height: 17px;
	  background: #008f85;
	  content: "";
	  position: absolute;
	  left: 0px;
	  top: 3px;
	}
	.contact-information ul {
	  width: 100%;
	  border-bottom: 1px solid #ddd;
	  padding-bottom: 55px;
	  box-sizing: border-box;
	}
	.contact-information ul li {
	  width: 100%;
	  margin-top: 20px;
	  color: #656565;
	  font-size: 15px;
	}
	.planting-code-p {
		color: #686868;
		font-size: 13px;
		text-align: center;
		width: 80%;
		margin: 15px auto;
	}
	.planting-code-p span {
		color: #15c081;
	} */
.sample-sending-information {
  width: 55px;
  margin-left: 40px;
  text-align: center;
  margin-top: 30px;
}
.sample-sending-information img {
  width: 100%;
}
.sample-sending-information span {
  font-size: 13px;
}
.planting-code-p1 {
  width: 94%;
  margin: 35px auto 20px;
  border-top: 1px solid #ddd;
  border-bottom: 1px solid #ddd;
  padding: 25px 0 40px;
  box-sizing: border-box;
  text-align: center;
}
.planting-code-p1 p {
  font-size: 12px;
  color: #676767;
}
.planting-code-p1 p span {
  color: #f4212d;
}
.planting-code-p2 {
  box-sizing: border-box;
  text-align: center;
  width: 94%;
  margin: 35px auto 20px;
}
.planting-code-p2 p {
  font-size: 12px;
  color: #656565;
}
.planting-code-p2 span {
  font-size: 24px;
  color: #39ad97;
  line-height: 1.8;
}
.planting-code-p1 button {
  padding: 10px 70px;
  box-sizing: border-box;
  background: #39ad97;
  border-radius: 30px;
  border: 0;
  color: #fff;
  margin-top: 15px;
}
</style>
